package com.erp.erp_servers.UserGroupMember.imp;

import com.erp.erp_dao.UserGroupMember.IUserGroupMemberDAO;
import com.erp.erp_entitys.UserGroupMember.UserGroupMemberEntity;
import com.erp.erp_entitys.UserGroupMember.UserGroupMemberEntityExample;
import com.erp.erp_servers.UserGroupMember.IUserGroupMemberService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @ClassName ImpUserGroupMemberService
 * @Description TODO
 * @Author songjizhen
 * @Date 2020-07-04 9:27
 * @Version 1.0
 */
@Service
public class ImpUserGroupMemberService implements IUserGroupMemberService {
    @Autowired
    IUserGroupMemberDAO userGroupMemberDAO;
    /**
     * 根据主键删除用户组成员
     *
     * @param id
     * @return
     */
    @Override
    public int deleteByPrimaryKey(Integer id) {
        return userGroupMemberDAO.deleteByPrimaryKey(id);
    }

    @Override
    public int deleteByExample(UserGroupMemberEntityExample example) {
        return userGroupMemberDAO.deleteByExample(example);
    }

    /**
     * 新增用户组成员
     *
     * @param record
     * @return
     */
    @Override
    public int insertSelective(UserGroupMemberEntity record) {
        return userGroupMemberDAO.insertSelective(record);
    }

    /**
     * 根据条件查询用户组成员
     *
     * @param record
     * @return
     */
    @Override
    public List<UserGroupMemberEntity> selectByExample(UserGroupMemberEntity record ) {
        UserGroupMemberEntityExample example=new UserGroupMemberEntityExample();
        UserGroupMemberEntityExample.Criteria criteria = example.createCriteria();
        if(record.getId() !=null ){
            criteria.andIdEqualTo(record.getId());
        }
        if(record.getGroupCode()!=null && record.getGroupCode() !=""){
            criteria.andGroupCodeEqualTo(record.getGroupCode());
        }
       if(record.getUserCode() !=null && record.getUserCode() !=""){
           criteria.andUserCodeEqualTo(record.getUserCode());
       }
        List<UserGroupMemberEntity> userGroupMemberEntities = userGroupMemberDAO.selectByExample(example);
        return userGroupMemberEntities;
    }
}
